import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface GlobalConfigState {
  theme: 'dark' | 'light';
}

const initialState: GlobalConfigState = {
  theme: 'dark',
};

export const globalConfigSlice = createSlice({
  name: 'globalConfig',
  initialState,
  reducers: {
    setTheme: (state, action: PayloadAction<GlobalConfigState['theme']>) => {
      state.theme = action.payload;
    },
  },
});

// 为每个 case reducer 函数生成 Action creators
export const { setTheme } = globalConfigSlice.actions;

export default globalConfigSlice.reducer;
